\section{Lexical Structure}

The lexical structure of Plaid is based on that of Java, as defined in
chapter 3 of the JLS.  Specifically:

\begin{itemize}

\pII{\item Plaid uses Unicode, as does Java (JLS section 3.1).}

\pII{\item Plaid supports the same lexical translations as Java (JLS section 3.2) and the same Unicode escapes (JLS section 3.3).}

\item Plaid uses the same definitions of line terminators as Java (JLS
  section 3.4), the same input elements and tokens (JLS section 3.5)
  except for a different keyword list, and the same definition of
  whitespace (JLS section 3.6).

\item Plaid uses the same definition of comments as Java (JLS section 3.7).

\item Plaid uses the same definition of identifiers as Java (JLS section 3.8).

\item Plaid uses the same definition of literals as Java (JLS section
  3.10) except that there is no Null Literal.  Furthermore, Boolean
  objects named \texttt{true} and \texttt{false} exist in the standard
  library, but unlike in Java these are not keywords in Plaid.
  \pI{Version 1.0 of Plaid supports only String literals, plus a
    restricted form of Integer literal which are strings of digits.}

\item Plaid uses the same definition of Separators as Java (JLS section 3.11).

\end{itemize}


\subsection{Keywords}

The following character sequences, formed from ASCII letters, are reserved
for use as \textit{keywords} and cannot be used as identifiers:

\begin{quote}
\ntermdef{Keyword} \oneof 
\end{quote}
\[
  \begin{array}{cccccc}
  \keyw{case} 
  & \keyw{default}
  & \keyw{import}
  & \keyw{fn}
  & \keyw{match}
  \\
  \keyw{method}
  & \keyw{new}
  & \keyw{of}
  & \keyw{overrides}
  & \keyw{package}
  \\
  \keyw{requires}
  & \keyw{state}
  & \keyw{this}
  & \keyw{val}
  \\
  \keyw{var}
  & \keyw{with}
  \\
  \vII{\keyw{dyn} & \keyw{dynamic} & \keyw{immutable} & \keyw{unique} & \keyw{none}}
  \end{array}
\]

%\TODO{The list above is only a current estimate, this will change as
%  we get the whole language defined.  Should also put the above into
%a nice table as in the JLS.}

%Note that \keyw{true} and \keyw{false} are actually boolean literals,
%as in Java.





\subsection{Operators}

We first define operator characters as follows:

\begin{quote}

\ntermdef{OperatorChar} \oneof

\defspace \texttt{= < > ! $\sim$ ? : \& | + - * / \^{} \%}

\end{quote}

Now an operator is a sequence of operator characters:

\begin{quote}

\ntermdef{Operator}

\defspace \nterm{OperatorChar}

\defspace \nterm{OperatorChar} \nterm{Operator}

\end{quote}

The exception to the grammar above is that the character sequences
\texttt{=}, \texttt{=>} and \texttt{<-} have other meanings in the
language and may not be used as operators.  Furthermore, operators
containing the comment seequences \texttt{/*} and \texttt{//} may not
be used as operators.
